<html>
<head>
   <script src="../../Grid/GridE.js"> </script>
</head>
<body class="Tutorial">
   <style>
      /* Tutorial shared styles */
      .Tutorial h1,.Tutorial h2,.Tutorial ul,.Tutorial .Desc,.Tutorial .Path,.Tutorial .Xml { max-height:999999px; }
      .Tutorial h1 { font:30px Arial; padding:5px 0px 5px 0px; margin:0px; text-align:center; }
      .Tutorial h2 { font:15px Arial; padding:0px; margin:0px 0px 10px 0px; text-align:center; color:#757575; }
      .Tutorial h3,.Tutorial h4 { display:inline-block; font:bold 15px Arial; padding:0px 5px 0px 5px; border-radius:2px; color:black; margin:2px; font-style:normal; color:#333; }
      .Tutorial h3 { background:#EE9; border:1px solid #DD8; }
      .Tutorial h4 { background:#BDE; border:1px solid #ACD; }
      .Tutorial a { text-decoration:underline; }      
      .Tutorial li { padding-bottom:8px; }
      .Tutorial ul { margin:6px 0px 0px 20px; font:13px Arial; }
      .Tutorial > ul { margin-left:0px; padding-left:15px; clear:both; }
      .Tutorial ul b { color:#0585B9; }
      .Tutorial .Path { font:normal 12px Arial; color:#0585B9; }
      .Tutorial .Path b { color:#D73938; }
      .Tutorial .Path u { text-decoration:none; color:black; font-weight:bold; padding:0px 2px 0px 2px; }
      .Tutorial .Xml { margin-bottom:6px; font-size:12px; color:#757575; }
      .Tutorial .Border { border:1px solid #dfdfdf; padding:10px 20px 10px 20px; margin:0px 8px 20px 0px; min-width:100%; box-sizing:border-box; }
      .Tutorial .Main { }
   </style>
   
   <center class="Path"><script>document.write(location.href.replace(/(.*)(\/Tutorials\/)([^\/]+)\/([^\/]+)$/,"$2<b>$3</b>/$4").replace(/([^<]|^)(\/|\.)/g,"$1<u>$2</u>"));</script></center>
   <h1>2. Master detail nested tables</h1>
   <h2>Master detail relation in plain tables shown as children of master rows</h2>

   <center class="Border" id="Border">
      <div class="Xml">Source: <a href='02-Master.js'>02-Master.js</a> &nbsp; <a href='02-Detail.js'>02-Detail.js</a></div>
      <div class="Main" style='width:100%; height:600px;'>
         <bdo Debug='check' DebugCheckIgnore='ADDRESS,NOTE,ADDRESSCopyTo,NOTECopyTo' Data_Url='02-Master.js'></bdo>
      </div>
   </center>

   <ul>
      <li>
         Plain master detail relation is used to show the same data in the expandable children in different layout.<br />
         <b>Master</b> grid shows the data in rows and <b>detail</b> grid shows the one master row data in different structure, often vertically in column.<br />
      </li>
      <li>
         The data are defined only in master grid, only master grid stores the changes and can upload them back to server.<br />
         Detail grid defines only layout, the columns and fixed (summary) rows.<br />
      </li>
      <li>
         The master data structure is usually defined in three levels tree: 
         <ul>
            <li>
               1. level <b>Data row</b>. The first level are the data rows displaying the data horizontally. They are the only defined rows, the other two levels are automatically created by grid according to the settings in row defaults.<br />
               The Data row default row (&lt;D>) should define the one child (Master row) with its Def set. And it should define also CopyTo attribute to copy the cells from Data row to Master row after their change.
            </li>
            <li>
               2. level <b>Master row</b>. The second level row is automatically created one child of the data row, usually fully spanned to show the detail grid in one (spanned) its cell.<br />
               This row is shown, when the Data row is expanded.<br />
               The Master row default (&lt;D>) row should define all the detail children, with appropriate cell values and other attributes and also with CopyTo attributes to copy the values from the Detail row cells to the Master row.<br />
               The Master row default (&lt;D>) row should also define appropriate CopyTo attributes to copy the cell values from Master row to Data row and also to Detail row.
               It should have set also <b>Expanded='0' CanExpand='0'</b> to never show the detail rows in master grid.<br />
            </li>
            <li>
               3. level <b>Detail row</b>. The third level rows are automatically created children of the master row. defined in the Master row default row.
            </li>
         </ul>
      </li>
      <li>
         Oposite to external detail grids you don't need to define the detail columns in master grid. <br />
         If you use debug='check' to check errors in your XML, you will receive warnings for unknown attributes for these columns in detail rows. In this case you can ignore these warnings. Or list them in DebugCheckIgnore.
      </li>
      <li>
         You can set attributes <b>Sync</b> and <b>SyncId</b> and optionally <b>CfgId</b> to synchronize all the detail grids.<br />
         For example if a user changes size of column in one detail grid, all other detail grids will be resized accordingly. Similarly for sorting, filtering, grouping and search settings.
      </li>
      <li>
         The &lt;D> cell attributes <h3>CopyTo</h3> will define which master cells will be copied to which detail row(s) and cells.<br />
         Usual value of the master CopyTo attribute is "Child_X,Y", where X is child row position from 0 and Y is column name.<br />
         For example NAMECopyTo='Child_2,VALUE' means that master row's NAME cell will be copied to the third child row, to the cell name VALUE.<br />
      </li>
      <li>
         The child row cell attributes <h3>CopyTo</h3> will define which detail cells will be copied to which master cells.<br />
         Usual value of the child CopyTo attribute is "Parent,Y", where Y is the master cell name.<br />
         For example VALUECopyTo='Parent,NAME' means that child row's VALUE cell will be copied to the master row's cell NAME.<br />
      </li>
      <li>
         <h4>How it works</h4><br />
         <ul>
            <li>
               On master grid load there will be created hidden children for every row according to the &lt;D> definition.<br />
               To these children attributes will be copied values from the root rows, according to the &lt;D> <b>CopyTo</b> attributes.<br />
            </li>
            <li>
               When some row in master grid is expanded to show the detail grid in children, all the master row's children are copied from master grid to detail grid and here are shown.<br />
               In this time are all the child rows at two placed (in master grid and in detail grid) and all changes are synchronized and mirrored to both.<br />
            </li>
            <li>
               When a user changes some value in master grid, in root row, the change is automatically copied to its hidden children and also mirrored to detail grid.<br />
               It is done by <b>CopyTo</b> attribute in &lt;D> tag, similarly to the grid loading.<br />
            </li>
            <li>
               When a user changes some value in detail grid, the change is mirrored to hidden child in master grid and also copied to the parent row.<br />
               It is done by <b>CopyTo</b> attribute in &lt;D> child &lt;I> tag.<br />
            </li>
         </ul>
      </li>
      <li>
         <h4>API</h4><br />
         On showing the master row in detail grid is called API event <b>OnShowDetail</b>.<br />
         After the row is shown is called <b>OnShowDetailFinish</b>.<br />
         To manually show some master row in detail grid call API method <b>ShowDetail</b>.<br />
         To refresh or clear detail grid call <b>RefreshDetail</b>.<br />
      </li>
   </ul>

   <!-- Google Analytics code run once for trial -->
   <script>
      var TGTrial = document.cookie.match(/TGTrialMaster\s*=\s*(\d+)/), TGIndex = 2;
      if(!TGTrial||!(TGTrial[1]&TGIndex)) setTimeout(function(){
         var n = "RunTrialGridMaster2", d = (new Date((new Date).getTime()+31536000000)).toUTCString(); document.cookie = "TGTrialMaster="+((TGTrial?TGTrial[1]:0)|TGIndex)+";expires="+d;
         var u = document.cookie.match(/TGTrialUsed\s*=\s*(\d+)/); u = u ? u[1]-0+1 : 1; if(u<=11) document.cookie = "TGTrialUsed="+u+";path=/;expires="+d;
         var s = "<div style='width:0px;height:0px;overflow:hidden;'><iframe src='http"+(document.location.protocol=="https"?"s":"")+"://www.treegrid.com/Stat/GA.html?productName="
               +(u==1||u==3||u==5||u==10?"UsedTrial"+u:n)+"' onload='var T=this;setTimeout(function(){document.body.removeChild(T.parentNode.parentNode);},1000);'/></div>";
         var F = document.createElement("div"); F.innerHTML = s; document.body.appendChild(F);
         },100);
   </script>
</body>
</html>